package com.pubinfo.passbook.engine.cell.logic;

import com.pubinfo.passbook.common.model.http.engine.ComputeParamSlot;
import com.pubinfo.passbook.engine.constants.ComputeChainType;
import com.pubinfo.passbook.engine.constants.ComputeResultType;

import java.math.BigDecimal;
import java.util.Arrays;
import java.util.Collection;

/**
 * @author zhouch
 * @date 2021/12/17 10:36
 */
public class ThanAndEqualUnit<T> extends ComputeLogicUnit<T, BigDecimal> {

    private static final ComputeParamSlot THAN_PARAM_SLOT = ComputeParamSlot.of("value", ComputeResultType.NUMBER);

    @Override
    public Collection<ComputeParamSlot> getParamSlots() {
        return Arrays.asList(
                THAN_PARAM_SLOT
        );
    }

    @Override
    public String getChainType() {
        return ComputeChainType.COMMON;
    }

    @Override
    public Boolean then(T data, BigDecimal result) {
        BigDecimal value = getParamenter(data, THAN_PARAM_SLOT.getName());
        return result.compareTo(value) >= 0;
    }
}
